#! /bin/sh
function check_item_def
{
	grep -q "[(,]$1)" ../item_def.h || echo "$1 missing"
}

function check_item_xml
{
	grep -q "^$1\$" check.$$ || echo "$1 will not be rendered"
}


awk '/<layout name="Car"/,/<\/layout/ { if (/<itemgra/) {print $0} }' < ../navit.xml | sed 's/.*item_types="\([^"]*\)".*/\1/' | tr "," "\012" | sort -u >check.$$
echo item_def.h
grep "^ITEM" ../item_def.h | sed -e "s/ITEM(\(.*\))/\1/" -e "s/ITEM2([^,]*,\(.*\))/\1/" |
while read -r x
do
	check_item_xml "$x"
done

rm -f check.$$
echo maptool.c
egrep '^	"[nw]	+[^	]+	+[^	]+' ../maptool.c | sed "s/.*	//" | sort -u |
while read -r x
do
	check_item_def "${x%%\\n\"}"
done

echo "navit.xml"
grep '<itemgra item_types="' <../navit.xml | cut -d \" -f 2 | tr "," "\012" |
while read -r x
do
	check_item_def "$x"
done

echo "garmintypes.txt"
grep "^[0-9]" ../map/garmin/garmintypes.txt | sed -e 's/[A-Z][A-Z]*, //' -e 's/.*= \([^,]*\),.*/\1/' | sort -u |
while read -r x
do
	check_item_def "$x"
done

